<?php

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\Notice;

/**
 * 公告接口
 */
class Notices extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * 公告列表
     */
    public function list(){

        $list = Notice::where('status','normal')->where('type_id',1)->order('sort desc')->paginate();

        $this->success(__('Get success'),$list);
    }

    /**
     * 详情
     */
    public function details(){
        $id = $this->request->get('id');
        if(!$id){
            $this->error(__('Invalid parameters'));
        }

        $data = Notice::where('status','normal')->where('type_id',1)->where('id',$id)->order('sort desc')->find();

        $this->success(__('Get success'),$data);
    }
}
